<?php
header("Content-Type:text/html;   charset=utf-8"); ?>
<script type="text/javascript">
    $(function(){
        //loadGirl();
        $("#btnQuery").bind("click",loadGirl);
        $("#btnQueryGirl").bind("click",loadGirl);
        $("#hrefDelGirl").bind("click",delSelectGirl);
        $("#hrefAddGirl").bind("click",addGirl);
    });
    function delSelectMultiGirl(ids){
        var params={ids:ids};
        var url="admin.php/girl/delGirl";
        $.ajax({
            type:"post",
            url:url,
            dataType:"json",
            data:params,
            success:function(data){

                if(data.ReturnCode=="1"){
                    loadGirl();
                    alert('删除成功');
                }else{
                    alert('删除失败');
                }
            }
        });
    }
    function delSelectGirl(){
        var selIds=getSelectIdsGirl();
        if(selIds==""){
            alert('请选择要删除的项');
            return;
        }
        if(confirm('删除后不可恢复，确认要删除吗？')==false)
            return;
        delSelectMultiGirl(selIds);
    }
    function delGirl(id){
        if(confirm('确定要删除吗？')==false)
            return;
        delSelectMultiGirl(id);
    }

    function getSelectIdsGirl(){
        var sel = "";
        $("#tableGirl td :checkbox:checked").each(function(){
            sel+=$(this).val()+",";
        });
        return sel;
    }
    function loadGirl(){
        $("#checkSelectAllGirl").attr("checked",false);
        var url="admin.php/girl/loadGirl";
        var params = {title:$("#txtTitle").val(),status:$("#txtStatus").val()};
        $.ajax({
            type:"post",
            url:url,
            data:params,
            dataType:"html",
            success:function(data){
                $("#tableGirl").html(data);
                //$(".pagination").html(data.page);
                bindSelect("checkSelectAllGirl","tableGirl");
            }
        });
    }
    function modifyGirl(id){
        $("#hrefEditGirl").attr("href","admin.php/girl/add_girl?id="+id);
        $("#hrefEditGirl").trigger("click");
    }
    function addGirl(){
        $("#hrefEditGirl").attr("href","admin.php/girl/add_girl");
        $("#hrefEditGirl").trigger("click");
    }
</script>
<form id="pagerForm" method="post" action="admin.php/girl/girl_list">
    <input type="hidden" name="numPerPage" value="20" />
    <input type="hidden" name="pageNum" value="1" />
</form>
<div class="pageHeader">
    <form>
        <div class="searchBar">
            <table class="searchContent">
                <tr>
                    <td>标题：<input type="text" id="txtTitle" class="textInput" /></td>
                    <td>分类：<select id="txtStatus">
                            <option value="">请选择</option>
                            <option value="1">显示</option>
                            <option value="0">隐藏</option>
                        </select></td>
                    <td>
                        <div class="subBar">
                            <ul>
                                <li><div class="buttonActive">
                                        <div class="buttonContent">
                                            <button style="width: 100px" type="button" id="btnQuery">查&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;询</button>
                                        </div>
                                    </div></li>
                            </ul>
                        </div>
                    </td>
                </tr>
            </table>

        </div>
    </form>
</div>
<div class="pageContent">
    <div class="panelBar">
        <ul class="toolBar">
            <li style="display: none"><a id="hrefEditGirl" class="edit" href=""
                                         lookupgroup="orgLookup"><span>修改</span></a></li>
            <li><a id="hrefAddGirl" class="add" href="javascript:void(0)"><span>添加人气女郎</span></a></li>
            <li><a id="hrefDelGirl" class="delete" href="javascript:void(0)"><span>删除</span></a></li>
        </ul>
    </div>
    <table class="table" width="100%" layoutH="138">
        <thead>
        <tr>
            <th style='width: 30px; text-align: center;'><input type='checkbox' id='checkSelectAllGirl' /></th>
            <th style='width: 40px'>编号</th>
            <th style='width: 300px'>标题</th>
            <th style='width: 100px'>城市</th>
            <th style='width: 50px'>uid</th>
            <th style='width: 50px'>姓名</th>
            <th style='width: 50px'>投票数</th>
            <th style='width: 50px'>是否推荐</th>
            <th style='width: 50px'>状态</th>
            <th style='width: 120px'>操作</th>
        </tr>
        </thead>
        <tbody id="tableGirl">
        <?php foreach($query['data'] as $row):?>
            <tr>
                <td><input type='checkbox' value='<?php echo $row['id'];?>' /></td>
                <td><?php echo $row['id'];?></td>
                <td><?php echo $row['title'];?></td>
                <td><?php echo $row['city'];?></td>
                <td><?php echo $row['uid'];?></td>
                <td><?php echo $row['name'];?></td>
                <td><?php echo $row['voteCount'];?></td>
                <td><?php echo $row['is_hot'] == 1 ?'是' : '否';?></td>
                <td><?php echo $row['status'] == 1 ?'显示' : '隐藏';?></td>
                <td>
                    <a href='javascript:void(0)' style='color:blue' onclick='modifyGirl(<?php echo $row['id'];?>)'>编辑</a>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <a href='javascript:void(0)' style='color:blue' onclick='delSelectMultiGirl(<?php echo $row['id'];?>)'>删除</a></td>
            </tr>
        <?php endforeach;?>
        </tbody>
    </table>
    <div class="panelBar">
        <div class="pages">

            <span>共<?php echo $query['sum'];?>条</span>
        </div>

        <div class="pagination" targetType="navTab" totalCount="<?php echo $query['sum'];?>" numPerPage="<?php echo $query['pageSize'];?>" pageNumShown="<?php echo $query['count'];?>" currentPage="<?php echo $query['page'];?>"></div>

    </div>
</div>